<?php

namespace App\Models;

use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\DB;
use Laravel\Passport\HasApiTokens;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Spatie\Permission\Traits\HasRoles;
use App\Notifications\ResetPasswordNotification;

class Member extends Authenticatable
{

    use HasApiTokens,Notifiable;


    protected $table = 'members';

    protected $fillable = ['phone','nickname','password','head_pic','remember_token'];

    protected $hidden = ['password','remember_token'];
    public    $timestamps = false;
    protected $primaryKey = 'member_id';
    /**
     * 返回用户数据
     * @param $id
     * @return mixed
     */
    public function getData($where){
        return self::where($where)
            ->first();
    }

    /**
     * 返回用户详细数据
     * @param $id
     * @return mixed
     */
    public function shows($id){

        return self::where(['member_id'=>$id])
            ->select('member_id','nickname','head_pic','phone')
            ->first();
    }


    /**
     * 检测手机号码是否已经注册
     * @return int
     */
    public function checkPhone($phone){
        $data = self::where(['phone'=>$phone])->first();
        if($data){
            return true;
        }else{
            return false;
        }
    }
}
